<template>
	<view class="content">
		<view class="topic-item" v-for="(item,index) in list1" :key="item.id">
			<view class="topic-img">
				<image :src="item.scene_pic_url" style="width: 100%;" mode="widthFix"></image>
			</view>
			<view class="ptitle">
				{{item.title}}
			</view>
			<view class="ctitle">
				{{item.subtitle}}
			</view>
			<view class="topic-price" style="color: red;">
				{{item.price_info | priceFormat}}
			</view>
		</view>
		<view class="topic-Tab">
			<u-subsection :list="list" :current="current" @change="sectionChange" inactiveColor="#cccc"
				activeColor="red"></u-subsection>
		</view>
		<customTabBar></customTabBar>
	</view>
</template>

<script>
	import customTabBar from "@/custom-tab-bar/index.vue"
	import {
		login,
		topicAPI
	} from "@/utils/api.js"
	export default {
		data() {
			return {
				list1: [],
				list2: [],
				list: ['上一页', '下一页'],
				// 或者如下，也可以配置keyName参数修改对象键名
				// list: [{name: '未付款'}, {name: '待评价'}, {name: '已付款'}],
				current: 0,
				// 默认第一页
				page: 1
			}
		},
		async onLoad() {
			let res = await topicAPI(this.page, 10)
			console.log(res);
			console.log(res.data.currentPage);
			let list = res.data.data
			this.list1 = list
			console.log("数组", this.list1);

		},
		methods: {
			async sectionChange(idx) {
				this.current = idx
				this.page = idx + 1
				console.log(this.page);
				let res = await topicAPI(this.page, 10)
				// console.log("888", res);
				console.log(res.data.currentPage);
				let list = res.data.data
				this.list1 = list
			}
		},
		components: {
			customTabBar
		},
		onShow() {
			this.$store.commit("changeTabBarIndex", 1)
		}
	}
</script>

<style lang="scss">
	.content {
		background-color: #efefef;
	}

	.topic-item {
		background-color: #fff;

		.ptitle,
		.ctitle,
		.topic-price {
			margin: 19rpx;
			text-align-last: center;
		}
	}

	.topic-Tab {
		margin: 30rpx 0 70rpx 0;
	}
</style>
